<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of confg
 *
 * @author Abhishek Lal
 */
//echo 'ok';
 $host = 'sql9.bravehost.com';
 $username = 'adhim';
 $password = 'm76bAoiR2IeThkFKj2GvWy';
 $dbname = 'adhim_2808730';
//
//
//
//$host = '127.0.0.1';
//$username = 'root';
//$password = '123456';
//$dbname = 'adhm';
//echo 'Connecting';
$con = mysqli_connect($host, $username, $password, $dbname) or die(mysqli_error($con));
//echo 
//mysql_select_db($dbname);

if (isset($_REQUEST['p']) && $_REQUEST['p'] != '') {
    $p = $_REQUEST['p'];
    $result = mysqli_query($con, "SELECT * FROM graphics where ID='$p'") or die(mysqli_error($con));
} else {
    if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') {
        $result = mysqli_query($con, "SELECT * FROM graphics where owner='" . $_REQUEST['u'] . "'") or die(mysqli_error($con));
    } else {
        if (isset($_COOKIE['username']) && $_COOKIE['username'] != '') {
            $result = mysqli_query($con, "SELECT * FROM graphics where owner='" . $_COOKIE['username'] . "'") or die(mysqli_error($con));
        } else {
            $result = mysqli_query($con, "SELECT * FROM graphics where owner='admin'") or die(mysqli_error($con));
        }
    }
//    echo 'asdasd'.mysqli_num_rows($result);
    if (mysqli_num_rows($result) <= 0) {
//        $result = mysqli_query($con, "SELECT * FROM graphics where owner='admin'") or die(mysqli_error($con));
    }
}

//$rowCnt = mysqli_num_rows($result);
//$rowRnd = rand(0, $rowCnt-1);
//mysqli_data_seek($result, $rowRnd);
$rowdata = mysqli_fetch_array($result);
?>
